var ResetPasswordPage=React.createClass({
    componentDidMount:function(){
        if(cookie.getCookie("studioId")!=""){
            window.location.href="index.html";
            
        }
    },
    resetPassword: function(){
        var password=$("#passWordInput").val();
        var password2=$("#passWordInput2").val();
        if (password == '') {   
            $("#error").text("输入不能为空！");
            return;
        }
        if (password != password2) {    
            $("#error").text("两次输入不一致！");
            return;
        }
        $("#error").text("");
        $.ajax({
            url:window.location.href,
            type:'POST',
            data:{
                newPassword:password
            },
            success:function(res){
                window.location.href="resetSuccess.html";
            },
            error:function(e){
                if(e.responseJSON.err==9004){
                    //账号密码错误
                    $("#error").text("链接非法！");
                }
            }
        });
    },
    handleKeyDown: function(event) {
        if (event.keyCode != 13) { // entry key
            return;
        }
        this.resetPassword();
    },
    render:function(){
        return (
        <div className="whiteBox">
            <h4 className="msg" style={{textAlign:"center"}}>现在您可以重新设置您的密码</h4>
            <div className="inputGroup">
                <label>&nbsp;新 密 码&nbsp;</label>
                <input type="password" className="Input" id="passWordInput"/>
            </div>
            <div className="inputGroup">
                <label>确认密码</label>
                <input type="password" className="Input" id="passWordInput2" onKeyDown={this.handleKeyDown}/>
            </div>
            <p id="error"></p>
            <div className="confirmBtn" onClick={this.resetPassword}></div>
        </div>
            );
    }
});
React.render(
  <ResetPasswordPage/>,
  document.getElementById('container')
);
